{% extends 'base.html' %}
{% block content %}

    <body>
        <div class="layui-fluid">
            <div class="layui-row">

                <form class="layui-form">

                    <!-- <div class="layui-form-item">
                        <label for="task_name" class="layui-form-label">任务类型</label>
                        <div class="layui-input-inline">
                            <select name="webtag" lay-verify="" lay-filter="webtag">
                                <option value="" disabled selected>选择任务类型</option>
                                {% for tag in tags %}
                                <option value="{{tag}}">{{tag}}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div> -->


                    <div class="layui-form-item">
                        <label for="task_name" class="layui-form-label">任务名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="task_name" name="task_name" required="" lay-verify="task_name" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    

                    <div class="layui-form-item">
                        <label for="targets" class="layui-form-label">目标列表</label>
                        <div class="layui-input-inline">
                            <textarea id="targets" name="targets" placeholder="xx.com|x.x.x.x/24" class="layui-textarea" style="word-wrap:normal;height: 285px;"></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="real_flag" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="add" lay-submit>确定添加</button>
                    </div>
                </form>

            </div>
        </div>
        <script>
            layui.use(['form', 'layer','laydate'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
                laydate = layui.laydate,
            
                //自定义验证规则
                form.verify({
                    task_name:[/\S/,'任务名称不能为空'],
                });

                //监听提交
                form.on('submit(add)',
                function(data) {
                    console.log(data.field);
                    $.post(data.form.action,data.field);
                    //发异步，把数据提交给服务端
                    layer.alert("增加成功", {icon: 6},
                        function() {
                        //关闭当前frame
                        xadmin.close();
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();

                    });
                    return false;

                });
                

            });
        </script>
    </body>
{% endblock %}